<template>
  <div style="display: inline-block; text-align: left">
    <el-button style="margin-bottom:10px" type="primary" class="buttoncss" icon="el-icon-edit" circle title="编辑" @click="dialogTableVisible = true"/>
    <el-dialog :visible.sync="dialogTableVisible" title="编辑" @close="close">
      <el-form ref="editData" label-position="left" label-width="70px" style="width: 400px; margin-left:50px;">
        <el-form-item :label="'name'" prop="name">
          <el-input v-model="editData.name"/>
        </el-form-item>
        <el-form-item :label="'role'" prop="role">
          <el-input v-model="editData.role"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm()">edit</el-button>
          <el-button @click="close()">cancel</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import '@/styles/buttonStyle.css'
import elDragDialog from '@/directive/el-dragDialog' // base on element-ui
import store from '@/store'
import { edit } from '@/api/shop_admin_auth/shopRole'

export default {
  name: 'DragDialogDemo',
  directives: { elDragDialog },
  props: {
    row_data: {
      type: Object,
      default: function() {
        return null
      }
    }
  },
  data() {
    return {
      dialogTableVisible: false,
      editData: {
      }
    }
  },
  created: function() {
    console.log(this.row_data)
    this.editData = this.row_data
  },
  methods: {
    submitForm() {
      edit(store.getters.token, this.editData).then(res => {
        this.close()
      })
    },
    close() {
      console.log(this.$parent.data)
      this.$emit('getLists')
      this.dialogTableVisible = false
    }
  }
}
</script>
